﻿using ClassLibraries;
using ModelLibrary;
using ModelLibrary.Contrls;
using System;
using System.Windows.Forms;

namespace IMS
{

    public partial class FmMain : Form
    {

        public FmMain()
        {
            InitializeComponent();
            this.plMenu.Width = AppSets.MainMenuWide;

        }
        private XTabControl tabControlMain = new XTabControl();

        private void FmMain_Load(object sender, EventArgs e)
        {
            FmMenu fmMenu = new FmMenu(new UserInfo());
            this.plMenu.Controls.Add(fmMenu);
            fmMenu.MenuCliked += FmMenu_MenuCliked;
            fmMenu.Dock = DockStyle.Fill;
            fmMenu.Show();

            TabPage tabPage = new TabPage("About Blak");
            tabControlMain.Controls.Add(tabPage);
            tabControlMain.Dock = DockStyle.Fill;
            this.plMain.Controls.Add(tabControlMain);
        }

        private void 高级设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 系统设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 菜单开关ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.plMenu.Width == AppSets.MainMenuWide)
            {
                this.plMenu.Width = 0;
            }
            else
                this.plMenu.Width = AppSets.MainMenuWide;
        }

        private void ClickedMenu()
        {

        }


        private void FmMenu_MenuCliked(object menu)
        {
            MainMenus mainMenus = (MainMenus)menu;
            foreach (TabPage item in tabControlMain.TabPages)
            {
                if (item.Text == mainMenus.Text)
                {
                    tabControlMain.SelectTab(item);
                    return;
                }
            }
            TabPage tabPage = new TabPage(mainMenus.Text);
            tabPage.Name = mainMenus.Name;
            FmExes.FmItemInfo fmItemInfo = new FmExes.FmItemInfo();
            fmItemInfo.TopLevel = false;
            fmItemInfo.FormBorderStyle = FormBorderStyle.None;
            fmItemInfo.Dock = DockStyle.Fill;
            tabPage.Controls.Add(fmItemInfo);
            fmItemInfo.Show();
            tabControlMain.TabPages.Add(tabPage);
            tabControlMain.SelectTab(tabPage);
        }

        private void 高级ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
    }
}
